<template>
	<view class="my">
		<!-- 自定义头部 start -->
		<view class="cu-custom" :style="[{ height: CustomBar + 'px' }]">
			<view class="cu-bar fixed" :style="{height: CustomBar + 'px',paddingTop: StatusBar + 'px',overflow: 'hidden'}">
				<image class="img-height" src="/static/my/my-background.png" mode="widthFix"
					style="position:absolute;top:0;width:100%;" />
				<view class="action"></view>
				<view v-if="showBarTitle" class="content text-white" :style="[{ top: StatusBar + 'px' }]">
					{{ i18n['个人中心'] }}
				</view>
				<!-- #ifndef MP-WEIXIN -->
				<view class="margin-right fu-top-action" v-if="false">
					<view class="fu-top-pic">
						<image class="fu-top-pic" :src="imgWechatUrl+'/my/top-1.png'" mode="aspectFill" @click="handleJump"
							data-url="/pages/index/setting/setting/index" />
					</view>
					<view class="margin-left-sm fu-top-pic fu-message" @click="handleJump"
						data-url="/pages/service-message/message/message-type/index">
						<image class="fu-top-pic" :src="imgWechatUrl+'/my/top-2.png'" mode="aspectFill" />
						<view class="fu-top-tag" v-if="messageNum != 0">{{ messageNum }}</view>
					</view>
				</view>
				<!-- #endif -->
			</view>
		</view>
		<view class="fu-my-background">
			<image src="/static/my/my-background.png" mode="aspectFill" class="w100 height-378" />
		</view>
		<view class="userInfo" id="userInfo" v-if="userInfo" @click="handleJump" data-url="/pages/user/user/info/index">
			<view class="tui-msg-box">
				<view class="flex flex-sub align-center">
					<view class="block-108 radius-16">
						<fu-image :src="storeInfo.store_logo" errorImg="/static/logo.png" mode="aspectFill" radius="50%">
						</fu-image>
					</view>
					<view class="margin-left fu-headpic-text">
						<view class="text-xl text-white">{{ storeInfo.store_name }}</view>
						<view class="flex align-center margin-top-6">
							<text class="text-sm margin-top-xs text-white fu-line-height">店铺星级：</text>
							<text class="cuIcon-favorfill text-white text-df" v-for="(item,index) in storeInfo.store_star"
								:key='index'></text>
							<!-- <image src="logo" mode="aspectFill" class="fu-block-24" v-for="(item,index) in storeInfo.store_star" :key='index'></image>							 -->
						</view>
						<view class="text-sm text-white margin-top-6">{{storeInfo.store_collection_num||0}}人关注</view>
					</view>
				</view>
			</view>
		</view>
		<view class="userInfo" v-else @click="handleJump" data-url="/pages/user/user/info/index">
			<view class="tui-msg-box">
				<view class="flex flex-sub align-center">
					<image src="/static/logo.png" class="fu-block-108 radius-16" mode="aspectFill"></image>
					<view class="margin-left">
						<view class="text-black text-xl text-white">{{ i18n['登录/注册'] }}</view>
					</view>
				</view>
				<view class="tui-msg-right"><text class="lg cuIcon-right"></text></view>
			</view>
		</view>
		<view class="bg-white radius-16 margin-top flex align-center justify-between fu-order-box margin-lr"
			@click="handleJump" data-url="/pages/wallet/my-wallet/index">
			<view class=" flex align-center ">
				<image src="/static/my/qb.png" mode="aspectFill" class="fu-block-143"></image>
				<view class="">
					<view class="text-price fu-fs32 text-bold text-333">{{storeInfo&&storeInfo.user_money||0}}</view>
					<text class="text-999 text-sm">余额（元）</text>
				</view>
			</view>
			<view class="bg-theme1 text-white padding-lr-36 text-sm padding-tb-10 radius-100 margin-right"
				@click.stop="handleJump" data-url="/pages/wallet/withdraw/index">提现</view>
		</view>
		<!-- 数据统计 start -->
		<view class="margin-lr    fu-order-box">
			<view class="flex justify-between align-center ">
				<view class="text-df text-black text-bold">数据统计</view>
				<view class="text-sm text-gray" @click="handleJump" data-url="/pages/wallet/withdraw-detail/statistics">
					<text class="cuIcon-right"></text>
				</view>
			</view>
			<view class="bg-white radius-16 margin-top-sm">
				<view class="flex my-order padding-tb-sm padding-lr-sm justify-center">
					
					<view class="flex align-center justify-center flex-direction w70">
						<view class="fu-fs44  text-bold  text-333 ">{{countInfo.all_stock_money||0}} </view>
						<view class="text-sm margin-top-sm">仓库总值</view>
					</view>
					
				</view>
				<view class="flex my-order padding-tb-sm padding-lr-sm">
					<view class="flex align-center justify-center flex-direction w33">
						<view class="fu-fs44  text-bold  text-333 ">{{countInfo.today_income||0}} </view>
						<view class="text-sm margin-top-sm">今日收入(元)</view>
					</view>
					<view class="flex align-center justify-center  flex-direction w34">
						<view class="fu-fs44  text-bold  text-333 ">{{countInfo.month_income||0}} </view>
						<view class="text-sm margin-top-sm">本月收入(元)</view>
					</view>
					<view class="flex align-center justify-center  flex-direction w33">
						<view class="fu-fs44  text-bold  text-333 ">{{countInfo.all_income||0}} </view>
						<view class="text-sm margin-top-sm">累计收入(元)</view>
					</view>
				</view>
				<view class="flex my-order padding-tb-sm padding-lr-sm">
					<view class="flex align-center  justify-center flex-direction w33">
						<view class="fu-fs44  text-bold  text-333 ">{{countInfo.today_order||0}} </view>
						<view class="text-sm margin-top-sm">今日订单(笔)</view>
					</view>
					<view class="flex align-center justify-center  flex-direction w34">
						<view class="fu-fs44  text-bold  text-333 ">{{countInfo.month_order||0}} </view>
						<view class="text-sm margin-top-sm">本月订单(笔)</view>
					</view>
					<view class="flex align-center justify-center  flex-direction w33">
						<view class="fu-fs44  text-bold  text-333 ">{{countInfo.all_order||0}} </view>
						<view class="text-sm margin-top-sm">累计订单(笔)</view>
					</view>
				</view>
			</view>
		</view>
		<!-- // run_type 1：入仓   2：非入仓 -->
		<view class="margin-top margin-lr bg-white radius-16">
			<view class="cu-list menu">
				<view class="flex align-center fu-list-item" v-if="userInfo&&userInfo.run_type==1" @click="handleJump"
					data-url="/pages/user/repairReport">
					<view class="fu-iconfont ml-30">
						<image class="fu-list-pic" src="/static/my/s1.png" mode="aspectFit" />
					</view>
					<view class="solid-bottom fu-item-main">
						<text class="text-block text-df">补仓申请</text>
						<image class="list-arrow" src="../../../../static/my/right-arrow.png" mode="aspectFit"></image>
					</view>
				</view>
				<view class="flex align-center fu-list-item" @click="handleJump" v-if="userInfo&&userInfo.run_type==1"
					data-url="/pages/user/supplyList">
					<view class="fu-iconfont ml-30">
						<image class="fu-list-pic" src="/static/my/s2.png" mode="aspectFit" />
					</view>
					<view class="solid-bottom fu-item-main">
						<text class="text-block text-df">供货单</text>
						<image class="list-arrow" src="../../../../static/my/right-arrow.png" mode="aspectFit"></image>
					</view>
				</view>
				<view class="flex align-center fu-list-item" @click="handleJump" data-url="/pages/index/setting/setting/index">
					<view class="fu-iconfont ml-30">
						<image class="fu-list-pic" src="/static/my/setting.png" mode="aspectFit" />
					</view>
					<view class="solid-bottom fu-item-main">
						<text class="text-block text-df">{{ i18n['设置'] }}</text>
						<image class="list-arrow" src="../../../../static/my/right-arrow.png" mode="aspectFit"></image>
					</view>
				</view>
				<view class="flex align-center fu-list-item" @click="handleJump" data-url="/pages/index/setting/about/index">
					<view class="fu-iconfont ml-30">
						<image class="fu-list-pic" src="/static/my/about.png" mode="aspectFit" />
					</view>
					<view class="solid-bottom fu-item-main">
						<text class="text-block text-df">关于我们</text>
						<image class="list-arrow" src="../../../../static/my/right-arrow.png" mode="aspectFit"></image>
					</view>
				</view>
				<view class="flex align-center fu-list-item">
					<view class="fu-iconfont ml-30">
						<image class="fu-list-pic" src="/static/my/kf.png" mode="aspectFit" />
					</view>
					<view class="solid-bottom fu-item-main">
						<text class="text-block text-df">联系客服</text>
						<view class="flex align-center" @tap='callPhone'>
							<text class="margin-right-sm">{{kfInfo.contact_tel}}</text>
							<image class="list-arrow" src="../../../../static/my/right-arrow.png" mode="aspectFit">
							</image>
						</view>
					</view>
				</view>
			</view>
		</view>
		<!-- 断网检测 -->
		<fu-notwork></fu-notwork>
	</view>
</template>

<script>
	/**
	 * @author 刘畅
	 */
	export default {
		data() {
			return {
				imgWechatUrl: this.imgWechatUrl,
				opacity: 0, // {Number} topBar的透明度
				invite_code: null, // {String} 邀请码
				autograph: null, // {String} 个性签名
				storeInfo: '', //店铺信息
				kfInfo: '', //客服信息
				countInfo: '', //数据统计
				showBarTitle: true // {Boolean} 是否显示barTitle
			};
		},
		onShow() {
			if (global.token) {
				this.getInfo();
				this.getCountInfo();
				this.$store.dispatch('getCartList');
				this.getKfInfo();
				this.getStorehouseInfo()
				console.log(global.userInfo.run_type, 'global.userInfo.run_type');
				if (global.userInfo&&global.userInfo.run_type == 1) {
					this.setTabBarItem1();
				} else { //非入仓
					this.setTabBarItem();
				}
			} else {

			}

		},
		computed: {
			// 用户信息
			userInfo() {
				return this.$store.getters.userInfo;
			}
		},
		onReachBottom(e) {
			// 触底触发加载数据
			this.$refs.guess && this.$refs.guess.loadData();
		},
		onPageScroll(e) {},
		methods: {
			/**
			 * @function
			 * @description 获取数据统计
			 */
			getCountInfo() {
				this.$api.post('/v1/640ecc45ba860').then(res => {
					if (res.data.code == 1) {
						this.countInfo = res.data.data;
					}
				});
			},

			/**
			 * @function
			 * @description 获取客服信息
			 */
			getKfInfo() {
				this.$api
					.post('/v1/63da1e62db3d0')
					.then(res => {
						if (res.data.code == 1) {
							this.kfInfo = res.data.data;
							uni.setStorageSync('kfNum', res.data.data.contact_tel)
						}
					})
					.catch(err => {
						console.log(err);
					});
			},
			callPhone() {
				uni.makePhoneCall({
					phoneNumber: this.kfInfo.contact_tel //仅为示例
				});
			},

			/**
			 * @function
			 * @description 获取店铺信息
			 */
			getInfo() {
				this.$api
					.post('/v1/6356316a22bb0', {
						partner_id: (global.userInfo && global.userInfo.id) || 0, //店铺id
						user_id: (global.userInfo && global.userInfo.id) || 0
					})
					.then(res => {
						res = res.data;
						if (res.code == 1) {
							this.storeInfo = res.data
							uni.setStorageSync('storeInfo', res.data)
							// this.$store.commit('updateUserInfo', res.data);
							this.$forceUpdate();
						}
						uni.stopPullDownRefresh();
					});
			},
			// 仓库信息
			getStorehouseInfo() {
				this.$api
					.post('/v1/63e4beec74810')
					.then(res => {
						res = res.data;
						if (res.code == 1) {
							uni.setStorageSync('storehouseInfo', res.data)
						}
						uni.stopPullDownRefresh();
					});
			},

			/**
			 * @event
			 * @description 复制邀请码
			 */
			copyingInvite_code() {
				const that = this;
				uni.setClipboardData({
					data: this.invite_code,
					success: function() {
						that.$message.info(that.i18n['复制成功']);
					}
				});
			},

		}
	};
</script>

<style lang="scss" scoped>
	.my {
		padding-bottom: 32rpx;
		position: relative;
		// background-image: url(../../../../stati);
	}

	.block-108 {
		width: 132rpx;
		min-width: 132rpx;
		height: 132rpx;
		min-height: 132rpx;
	}

	.userInfo {
		margin-bottom: 20rpx;
		padding: 20rpx 0 0 30rpx;
		position: relative;
		z-index: 2;
	}

	.tui-msg-box {
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	// 我的订单 start
	.my-order {
		image {
			width: 50rpx;
			height: 50rpx;
		}

		.item {
			position: relative;

			.jiaobiao {
				position: absolute;
				top: -20rpx;
				right: 30rpx;
				color: #FFFFFF;
				font-size: 24rpx;
				background-color: #FF6464;
				border-radius: 100rpx;
				width: 40rpx;
				height: 40rpx;
				line-height: 38rpx;
				text-align: center;
				z-index: 9;
				transform: scale(0.65);
			}
		}
	}

	// 我的订单 end

	.ml-30 {
		margin-right: 20rpx;
		margin-left: 10rpx;
		height: 40rpx;
	}

	// 头像旁边名字
	.fu-headpic-text {
		display: flex;
		flex-direction: column;
		justify-content: space-around;
		height: 128rpx;

		.fu-line-height {
			line-height: 34rpx;
		}
	}

	// 背景图片
	.fu-my-background {
		position: absolute;
		top: 0;
		// z-index: -1;
		width: 100%;

		image {
			width: 100%;
		}
	}

	.fu-list-item {
		height: 110rpx;
		width: 100%;
		padding: 0 32rpx 0 32rpx;

		.fu-list-pic {
			width: 40rpx;
			height: 40rpx;
		}

		.list-arrow {
			width: 14rpx;
			height: 30rpx;
		}

		.fu-item-main {
			display: flex;
			justify-content: space-between;
			align-items: center;
			height: 110rpx;
			width: 100%;
		}
	}

	// 头像
	.fu-top-pic {
		width: 40rpx;
		height: 40rpx;
	}

	// 复制标签
	.fu-copy-invite {
		display: inline-block;
		width: 60rpx;
		height: 34rpx;
		text-align: center;
		line-height: 34rpx;
		border-radius: 6rpx;
		background-color: rgba(255, 255, 255, 0.5);
	}

	// topBar功能入口
	.fu-top-action {
		display: flex;

		.fu-top-pic {
			width: 40rpx;
			height: 40rpx;
		}

		.fu-message {
			position: relative;

			.fu-top-tag {
				position: absolute;
				top: -12rpx;
				right: -12rpx;
				/* width: 25rpx; */
				/* height: 25rpx; */
				/* padding:3rpx; */
				text-align: center;
				line-height: 25rpx;
				font-size: 24rpx;
				color: #ff6464;
				background-color: #fff;
				border: 1rpx solid #ff6464;
				width: auto;
				height: 32rpx;
				line-height: 32rpx;
				border-radius: 32rpx;
				min-width: 32rpx;
				padding: 0 4rpx;
			}
		}
	}

	// 快捷功能入口
	.fu-month-in {
		height: 158rpx;
		margin-top: 60rpx;
		position: relative;
		z-index: 2;

		.fu-in-item {
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: space-around;
			height: 158rpx;
		}
	}

	.fu-order-box {
		position: relative;
		z-index: 2;
		margin-top: 46rpx;
	}

	// 签到
	.fu-signin {
		width: 160rpx;
		height: 72rpx;
		text-align: center;
		line-height: 72rpx;
		background-color: #ffe36c;
		color: $theme;
		border-radius: 36rpx 0 0 36rpx;
	}

	.tui-msg-right {
		margin-right: 24rpx;
		color: #fff;
	}
</style>